package com.base.controller;

import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.base.po.voip.Callnums;
import com.base.service.CallNumService;
import com.base.utils.Produce;

/**
 * 回拨号码信息服务端
 * 
 * @author f 优化日期：10-16
 *
 */
@Controller
@RequestMapping("/admin")
public class DialIndexController {

	@Autowired
	private CallNumService callNumService; // 回拨号码Service

	// 回拨号码主页
	@RequestMapping("/dial_index")
	public ModelAndView index(HttpSession session) throws Exception {
		Object obj_id = session.getAttribute("adminUserId"); // 登录的用户ID
		if (obj_id == null) {
			return new ModelAndView("jsp/loginCheck"); // 未登录
		}
		Callnums call = callNumService.selectByAgentKey((String) obj_id); // 回拨号码
		if (call == null) { // 没有电话信息
			call = (call = callNumService.selectByAgentKey("7dd9a07e-9cef-4702-a165-b7033861c1b7")) == null ? new Callnums()
					: call; // ADMIN
			call.setId(Produce.getUUID()); // 新的主键ID
		}
		return new ModelAndView("jsp/dial_index", "call", call);
	}
}
